package cn.tedu.oop2;

public class TestExtends {
    public static void main(String[] args) {
        Animal a=new Animal();
        Animal show = a.show();
        System.out.println(show);

        new Animal().eat();
        new Animal().show();
        new Cat().eat();
        new Cat().show();
        new Dog().eat();
        new Dog().show();
        int sum = a.sum();
        System.out.println(sum);

    }
}
class Animal{
    public int sum(){
        return 5;
    }
    public void eat(){
        System.out.println("小动物Animal吃啥都行");
    }
    public Animal show(){
        System.out.println("我是一只小动物");
        Animal a=new Animal();
        return a;
    }

}
class Cat extends Animal{
    @Override
    public void eat(){
        System.out.println("小猫爱吃小鱼干");
    }
    public Cat show(){
        System.out.println("我是一只小猫");
        return null;
    }
}
class Dog extends Animal{
    public void eat(){
        System.out.println("小狗爱吃肉骨头");
    }
    public Dog show(){
        System.out.println("我是一只小狗");
        return null;
    }

}